package com.bjsy.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一返回对象
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {

    //返回码
    private Integer code;
    //返回消息
    private String msg;
    //返回数据
    private Object data;

    //操作成功
    public static Result success(Object data) {
        return new Result(200, "success", data);
    }

    //操作失败
    public static Result fail(Integer code, String msg) {
        return new Result(code, msg, null);
    }

    public static Result fail(ResultEnum resultEnum) {
        return new Result(resultEnum.getCode(), resultEnum.getMsg(), null);
    }
}
